/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-14 13:20:23
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Fence.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    CommonButton,
    OpenTwoRouter,
    OpenSelection,
} from '../Common/options'

export const Fence = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
            <OpenSelection
                danger
                key="delete"
                title="批量删除"
                type="primary"
                OptionsEvent={OptionsEvent}
                data={{ type: 'SelectionDelete', url: 'posBatchRemoveFence' }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            commonTableList.tableName,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,

                        <CommonButton
                            key="one"
                            OptionsEvent={OptionsEvent}
                            title="电子围栏"
                            data={{
                                smallTitle: record.tableName + ' 电子围栏详情',
                                type: 'FenceMapModal',
                                record,
                                width: '80vw',
                                actionRef,
                            }}
                        />,

                        <OpenTwoRouter
                            key="TwoOne"
                            title="人员配置"
                            twoTitle="电子围栏打卡人员配置"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'Fence',
                                actionRef,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
